<template>
	<Layout :class="'bg-white p-2'">
		<Row class="p-1">
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.warehouseName" placeholder="请输入仓库名称" />
			</Col>
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.batchNo" placeholder="请输入出库批次号" />
			</Col>
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.userName" placeholder="请输入管理员姓名" />
			</Col>
		</Row>	
		<Row class="p-1">	
			<Col class="p-1" span="4">
				<Input class="w-100" v-model="searchKey.saleBatchNo" placeholder="请输入销售批次号" />
			</Col>
			<Col class="p-1" span="4">
				<Date-picker format="yyyy-MM-dd HH:mm:ss" type="datetime" @on-change="sChange" placeholder="选择开始时间"></Date-picker>
			</Col>
			<Col class="p-1" span="4">
				<Date-picker format="yyyy-MM-dd HH:mm:ss" type="datetime" @on-change="eChange" placeholder="选择结束时间"></Date-picker>
			</Col>
		</Row>
		
		<Row class="p-1">
			<Button class="m-1 float-right" type="primary" @click="search">查询</Button>
			<Button class="m-1 float-left" type="error"   @click="newFlow">新增</Button>
		</Row>
		
		<Layout :class="'bg-white'">
			<Table border :class="'m-2'" :columns="tableInfo.columnInfo" :data="tableInfo.data">
				<template slot-scope="{ row, index }" slot="action">
					<Button size="small" style="margin-right: 5px"
						@click="switchPage(row.outboundHeaderId)">详细</Button>
				</template>
			</Table>
			<Page :class="'m-2 text-right'" :page-size="tableInfo.pageSize" @on-change="pageSearch"
				:total="tableInfo.total" />
		</Layout>
	</Layout>
</template>

<script>
	export default {
		data: function() {
			return {
				searchKey: {					
					batchNo: "",					
					storeId: "",
					userName: "",
					saleBatchNo: "",
					warehouseName: "",
					startDate: "",
					endDate: "",
					current: 1,
					size: 10
				},
				tableInfo: {
					currentPage: 1,
					total: 0,
					columnInfo: [{
							title: "出库批次号",
							align: 'center',
							key: "batchNo",
							width: 100
						},
						{
							title: "出库时间",
							align: 'center',
							key: "date",
							width: 150
						},
						{
							title: "仓库名称",
							align: 'center',
							key: "warehouseName",
							width: 150
						},
						{
							title: "销售批次号",
							align: 'center',
							key: "saleBatchNo ",
							width: 150
						},						
						{
							title: "仓库管理员",
							align: 'center',
							key: "userName",
							width: 120
						},
						{
							title: "操作",
							align: 'center',
							slot: 'action'
						}
					],
					data: []
				},
			};
		},
		created: function() {
			//this.searchKey.storeId = 本地缓存中的门店id
			this.search();
		},
		methods: {
			search: function() {
				this.searchKey.current = 1;
				this.loadData();
			},
			sChange: function(s) {
				this.searchKey.startDateStart = s;
			},
			eChange: function(e) {
				this.searchKey.endDateEnd = e;
			},
			loadData: function() {
				this.http.get({
					url: "/outbound/page/g",
					param: this.searchKey
				}).then(data => {
					this.tableInfo.currentPage = data.current;
					this.tableInfo.total = data.total;
					this.tableInfo.pageSize = data.size;
					this.tableInfo.data = data.records;
				});
			},
			pageSearch: function(changedPage) {
				this.searchKey.current = changedPage;
				this.loadData();
			},
			switchPage: function(outboundHeaderId) {
				this.$router.push({
					path: "/outbound/detail?outboundHeaderId=" + outboundHeaderId,
				});
			},
			newFlow: function() {
				this.$router.push({
					path: "/outbound/new",
				});
			},
		}
	}
</script>

<style>
</style>
